import { request } from '@gui-pkg/request';
import axios from 'axios';
import { useUserStoreWithOut } from '@/store/modules/user'
enum Api {
  GetOne = '/api/warnrule/',
  StationList = '/api/warnrule/page',
  AddStation = '/api/warnrule/save',
  FindAll = '/api/warnrule/findAll',
  DeleteBatch = '/api/warnrule/del/batch',
  DeleteStation = '/api/warnrule/',

  targetList = '/api/warntarget/page',
  addtarget = '/api/warntarget/save',
  deltarget = '/api/warntarget/delete/',
  targetListAll = '/api/warntarget/findAll',

  updateStatus = '/api/warntarget/updateStatus',

  AddExcel = '/api/warnrule/uploadFile',
}

export const updateTargetStatus = (params) => {
  return request.post({ url: Api.updateStatus, params });
};

export const getTargetListAll = () => {
  return request.get({ url: Api.targetListAll });
};
export const getTargetList = (params) => {
  return request.get({ url: Api.targetList, params });
};

export const addtargetData = (params) => {
  return request.post({ url: Api.addtarget, params });
};

export const deltargetData = (params) => {
  return request.post({ url: Api.deltarget+params });
};

// 获取单个测站信息
export const getOneStationData = (id) => {
  return request.get({ url: `/api/warnrule/${id}` });
};

// 获取列表
export const getStationList = (params) => {
  return request.get({ url: Api.StationList, params });
};

// 新增编辑
export const addStationData = (params) => {
  return request.post({ url: Api.AddStation, params });
};

// 获取所有数据
export const getAllStationData = (params) => {
  return request.post({ url: Api.FindAll, params });
};

// 批量删除
export const deleteBatch = (params) => {
  return request.post({ url: Api.DeleteBatch, params });
};

// 删除测站
export const deleteStationData = (params) => {
  return request.post({ url: Api.DeleteStation + params });
};
const PUBLIC_PATH:string =   JSON.parse(import.meta.env.VITE_GLOB_API_URL) ;
const userStore = useUserStoreWithOut();

export const bacthImportData = (formData) => {
  return axios.post(PUBLIC_PATH[0][1] +Api.AddExcel, formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
      'authorization':userStore.getToken
    }
  });
};
